package com.baoyouqun.domain.UpdateCmd;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Data;

/**
 * 积分核销编辑命令
 */
@Data
public class UserPointsWriteOffUpdateCmd {
    @NotBlank(message = "100301:核销记录ID不能为空")
    @ApiModelProperty(value = "核销记录ID（必填）")
    private String id;

    @NotNull(message = "100301:核销积分数不能为空")
    @Positive(message = "100305:核销积分数必须为正数")
    @ApiModelProperty(value = "新核销积分数（正数，后端自动转为负数，必填）")

    private Integer newWriteOffPoints;
    @ApiModelProperty(value = "类型描述")
    private String type;

    @NotBlank(message = "100301:核销描述不能为空")
    @ApiModelProperty(value = "新核销描述（必填）")
    private String newBizDesc;

    /**
     * 校验核销描述长度
     */
    public boolean isValidNewBizDesc() {
        return StrUtil.isBlank(newBizDesc) || newBizDesc.length() <= 200;
    }

    public String getNewBizDescErrorMsg() {
        return "100306:核销描述不能超过200个字符";
    }
}